package com.fuyao.cloud.daemon.quartz.task;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.fuyao.cloud.admin.api.feign.RemoteUserService;
import com.fuyao.cloud.common.core.constant.SecurityConstants;
import com.fuyao.cloud.daemon.quartz.constants.CloudQuartzEnum;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 检测用户密码修改，如90天没有修改密码则提添加一条系统提示消息
 *
 * @author lyhil
 * @date 2022年5月5日
 */
@Slf4j
@Component("userUpdatePasswordCheck")
@AllArgsConstructor
public class UserUpdatePasswordCheck {

    private final RemoteUserService userService;

    /**
     * 执行方法
     */
    @SneakyThrows
    public String run() {
        log.info(" run date start time :{}", LocalDateTimeUtil.now());
        try {
            this.userService.selectUserUpdatePasswordUserList(SecurityConstants.FROM_IN);
        } catch (Exception e) {
            log.error("执行用户修改密码检测定时任务数据异常：" + e.getMessage());
            return CloudQuartzEnum.JOB_LOG_STATUS_FAIL.getType();
        }
        log.info(" run date end time :{}", LocalDateTimeUtil.now());
        return CloudQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
    }
}
